﻿<!doctype html>
<html lang="">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

    <title>@ViewBag.Title</title>

    <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    @Scripts.Render("~/bundles/jquery")
</head>

<body>
    <div class="app">
        @* Thanh menu top *@
        @Html.Partial("_Navbar")
        <section class="layout">

            @* Menu ben trai *@
            @Html.Partial("_SideBar")

            <section class="main-content">

                <div class="content-wrap">
                    <div class="wrapper p10" id="content-main">
                        @* Phan noi dung chinh *@
                        @RenderBody()

                        
                    </div>
                    <div id="loading-icon" >
                        <img src="~/Content/css/img/loading.gif" />
                    </div>
                </div>

                <a class="exit-offscreen"></a>
            </section>

            @Html.Partial("_ChatPanel")
        </section>
    </div>
    <div id="notification"></div>

    @Scripts.Render("~/bundles/script")

    @Styles.Render("~/Content/css/admin")

    @Scripts.Render("~/bundles/jqueryval")
    <script>
        $("#loading-icon").hide();
        function AjaxBegin()
        {
            $('#loading-icon').show();

        }
        function AjaxComplete()
        {
            $("#loading-icon").hide();
        }
        function AjaxFailure(ajaxContext)
        {
            var response = ajaxContext.responseText;
            alert("Error: [" + ajaxContext.ErrorCode + "] " + response);
        }


        function onEdit(e)
        {
            //if (e.model.isNew())
            //{
            //    $('.k-window-title').text("Thêm mới");
            //    //e.container.find("label:first").hide();
            //}
            //else
            //{
            //    $('.k-window-title').text("Sửa dữ liệu");
            //}
        }

        function onRequestEnd(e)
        {
            var grid = $("#griddata").data("kendoGrid");
            var data = grid.dataSource;
            if (e.type == "create" || e.type == "update" || e.type == "destroy")
            {
                var notification = $("#notification").kendoNotification().data("kendoNotification");

                if (!e.response.Errors)
                {
                    if (e.type == "create")
                        data.read();
                    notification.show("Thực hiện thao tác thành công.", "info");
                }
            }
        }

        function onError(e, status)
        {
            if (e.errors)
            {
                var message = "The following errors have occurred:\n";

                $.each(e.errors, function (key, value)
                {
                    if (value.errors)
                    {
                        message += value.errors.join("\n");
                    }
                });

                alert(message);
            }
        }

    </script>
</body>

</html>
